//
//  AboutMeController.m
//  meiyinxiang
//
//  Created by 媒印象 on 09/12/2017.
//  Copyright © 2017 hbjApple. All rights reserved.
//

#import "AboutMeController.h"
#import "IntroduceController.h"
@interface AboutMeController ()<UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *founctionIntroduction;
@property (weak, nonatomic) IBOutlet UIView *checkNewVersion;

@end

@implementation AboutMeController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    self.title = @"关于媒印象";
    [self addTapGes];
    //获取当前版本号
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    NSString *currentAppVersion = infoDic[@"CFBundleShortVersionString"];
    UILabel *versionLabel = [self.checkNewVersion viewWithTag:11];
    versionLabel.text = currentAppVersion;
    
}
- (void)addTapGes{
    UITapGestureRecognizer *founctionViewGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(founctionAct)];
    self.founctionIntroduction.userInteractionEnabled = YES;
    [self.founctionIntroduction addGestureRecognizer:founctionViewGes];
    UITapGestureRecognizer *checkViewGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(checkAct)];
    self.checkNewVersion.userInteractionEnabled = YES;
    [self.checkNewVersion addGestureRecognizer:checkViewGes];
    
}
- (void)founctionAct{
    IntroduceController *introduceVC = [IntroduceController loadNibWitbIntroduceVC];
    [self.navigationController pushViewController:introduceVC animated:YES];
}
- (void)checkAct{
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    NSString *currentAppVersion = infoDic[@"CFBundleShortVersionString"];
     UILabel *versionLabel = [self.checkNewVersion viewWithTag:11];
    [[MYXHttpManager shared] checkVersionWithResult:^(BOOL sucess, NSString *msg) {
        if (sucess) {
            if (![currentAppVersion isEqualToString:msg]) {
                showAlert(@"更新app版本");
            }else{
                versionLabel.text = @"当前已是最新版本";
            }
        }
    }];
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/%E5%AA%92%E5%8D%B0%E8%B1%A1/id1319623958?l=en&mt=8"]];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
+ (AboutMeController *)loadNibWithMeVC{
    UINib *nib = [UINib nibWithNibName:@"AboutMeController" bundle:[NSBundle mainBundle]];
    return [[nib instantiateWithOwner:nil options:nil] lastObject];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
